package com.team.childapp.ui

import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.os.Handler
import android.os.Looper
import androidx.core.app.ActivityCompat
import com.team.childapp.R
import com.team.childapp.base.App
import com.team.childapp.base.activity.BaseActivity
import com.team.childapp.databinding.ActivitySplashBinding
import com.team.childapp.ui.login.RegisterActivity
import com.team.childapp.ui.study.StudyActivity
import kotlinx.coroutines.NonCancellable.start

/**
 * 作者：suichengju
 * 时间：2024/12/17:18:10
 * 邮箱：325927775@qq.com
 * 说明：
 */
@SuppressLint("CustomSplashScreen")
class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_splash) {
    override fun initData() {
        translucentWindow(false)
        startCountdown()
    }

    override fun initView() {
        mBinding.btnSkip.setOnClickListener {
            nextPage()
        }
    }

    private fun requestPermission() {

    }

    private fun startCountdown() {
//        Handler(Looper.getMainLooper()).postDelayed({
//            nextPage()
//        }, 2000) // 2000 milliseconds = 2 seconds
        App.application().getHandler().postDelayed({
            nextPage()
        }, 2500)
    }

    override fun onDestroy() {
        super.onDestroy()
        App.application().getHandler().removeCallbacksAndMessages(null)
    }

    private fun nextPage() {
        //            start<MainActivity>()
        start<WelcomeActivity>()
//        start<RegisterActivity>()
        finish()
    }

}